#!/usr/bin/python
# -*- coding: utf-8 -*-

'''
Introduction to Programming in Java - An Interdisciplinary Approach

All book programs ported to Python by
Scott C. King (revisionx at {gee}ma1l <dot> c0m).

All program examples pass Pylint with a perfect 10.00 score.
Pylint:  http://www.pylint.org/


# Program 1.2.2 - Integer multiplication and division

Syntax:
python intops.py 25 75


Notes:
sys is a required import here in order to use command line arguments.
https://docs.python.org/2/tutorial/stdlib.html

int(sys.argv[x]) == Integer.parseInt(args[x])

Python's print statement does not automatically convert
int values to strings, so this must be performed manually.

Variables renamed to be 'Pythonic':
https://docs.python.org/2/glossary.html

The PEP8 Style Guide limits lines to 79 character:
https://www.python.org/dev/peps/pep-0008/#maximum-line-length


While there is no internal distinction between a module and a script
in Python, it's good practice to separate the executable code from the
importable code.  Traditionally, this is performed using the construct
presented below. If imported, foo's code is available.  If executed, foo's
code is not available and everything in "main" executes (code in main
can access foo).  Program ports henceforth will follow this format.

def foo():
    """ foo's docstring """
    foo's code goes here

def main():
    """ main's docstring """
    main's code goes here

if __name__ == '__main__':
    main()

'''

import sys


def main():
    ''' Program 1.2.2 - Integer multiplication and division '''

    arg1 = int(sys.argv[1])
    arg2 = int(sys.argv[2])
    product = arg1 * arg2
    quotient = arg1 / arg2
    modulo = arg1 % arg2

    print str(arg1) + " * " + str(arg2) + " = " + str(product)
    print str(arg1) + " / " + str(arg2) + " = " + str(quotient)
    print str(arg1) + " % " + str(arg2) + " = " + str(modulo)
    print str(arg1) + " = " + str(quotient) + " * " + str(arg2) + \
          " + " + str(modulo)

    # Alternate using the built-in string class' format method
    print
    print "{} * {} = {}".format(str(arg1), str(arg2), str(product))
    print "{} / {} = {}".format(str(arg1), str(arg2), str(quotient))
    print "{} % {} = {}".format(str(arg1), str(arg2), str(modulo))
    print "{} = {} * {} + {}".format(str(arg1), str(quotient),
                                     str(arg2), str(modulo))


if __name__ == '__main__':
    main()
